﻿package core.ui.controls
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;

    public class Tab extends Sprite
    {
        private var marked:Boolean;
        private var bg:Sprite;
        private var icon:Bitmap;
        private var ln:Text;

        public function Tab(param1:String, param2:BitmapData, param3:String)
        {
            this.name = param1;
            this.bg = new Sprite();
            addChild(this.bg);
            this.icon = new Bitmap(param2);
            this.icon.x = 10;
            addChild(this.icon);
            this.ln = new Text(U.RM(param3), 13, 2236962, false, false);
            this.ln.x = 28;
            this.ln.text = this.ln.text.substr(0, 20);
            addChild(this.ln);
            this.addEventListener(MouseEvent.MOUSE_OVER, this.MouseOver, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OUT, this.MouseOut, false, 0, true);
            var _loc_4:* = this.width + 20;
            var _loc_5:* = 30;
            this.bg.graphics.beginFill(7171437);
            this.bg.graphics.drawRect(0, 2, _loc_4, _loc_5 - 3);
            this.bg.graphics.beginFill(6579300);
            this.bg.graphics.drawRect(1, 2, _loc_4 - 2, _loc_5 - 3);
            this.bg.graphics.beginFill(15987699);
            this.bg.graphics.drawRect(2, 0, _loc_4 - 4, _loc_5);
            var _loc_6:* = new Matrix();
            _loc_6.createGradientBox(_loc_4 - 4, (_loc_5 - 1), 90 / (180 / Math.PI), 0, 0);
            this.bg.graphics.beginGradientFill("linear", [14474460, 12961221], [1, 1], [0, 255], _loc_6);
            this.bg.graphics.drawRect(2, 1, _loc_4 - 4, (_loc_5 - 1));
            this.bg.graphics.endFill();
            this.Mark(false);
            return;
        }// end function

        private function MouseOver(... args) : void
        {
            if (!this.marked)
            {
                this.alpha = 1;
            }
            return;
        }// end function

        private function MouseOut(... args) : void
        {
            if (!this.marked)
            {
                this.alpha = 0.55;
            }
            return;
        }// end function

        public function Mark(param1:Boolean = true)
        {
            this.marked = param1;
            if (param1)
            {
                this.ln.y = 5;
                this.icon.y = 8;
                this.alpha = 1;
                this.bg.alpha = 1;
            }
            else
            {
                this.ln.y = 4;
                this.icon.y = 7;
                this.alpha = 0.55;
                this.bg.alpha = 0;
            }
            return;
        }// end function

    }
}
